package com.acme.bankapp.util;

/**
 * Blocking queue
 * @author Gregory Sobko
 */
public interface ConcurrentQueue<T> {

    /**
     * pops element from Q, or puts thread to wait if no element in Q
     * @return element
     * @throws InterruptedException if thread was interrupted from wait
     */
    T pop() throws InterruptedException;

    /**
     * non-waiting pop
     * @return element or null if no element in Q.
     */
    T tryPop();

    /**
     * puts element in queue or puts to wait if queue is full
     * @param element element to put in queue
     * @throws InterruptedException
     */
    void push(T element) throws InterruptedException;

    /**
     * closes queue, preventing from pushing new elements
     */
    void close();
}
